package Classwork;

public class HK {
    public static void main(String[] args) {
    int[] arr= {1,7,5,3,0,9,6,8};
    quickSort(arr,0,arr.length-1);
    for(int i=0;i<arr.length;i++) {
        System.out.print(arr[i]+" ");
    }
}
    public static void quickSort(int[] arr,int left,int right)//定义一种方法
    {
        if(left>right) {
            return;
        }//左边一定小于右边
        int base=arr[left];
        int i=left;
        int j=right;
        while(i!=j) {
            while(arr[j]>=base&&i<j) {
                j--;
            }
            while(arr[i]<=base&&i<j) {
                i++;
            }
            int temp=arr[i];
            arr[i]=arr[j];
            arr[j]=temp;
        }
        arr[left]=arr[i];
        arr[i]=base;
        quickSort(arr,left,i-1);
        quickSort(arr,j+1,right);
    }
}

